package workers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import messaging.IMessagingHandler;
import messaging.JMSMessagingConstants;
import messaging.SoftwareDevelopmentMessagingHandler;
import model.Software;
import workerUIs.StepFrame;
import workflow.step.ReleaseStep;

public class ReleaseStepWorker extends AbstractStepSwingWorker {
	
	public ReleaseStepWorker(StepFrame frame,
			IMessagingHandler<Software> messagingHandler) {
		super(frame, messagingHandler);
	}

	@Override
	protected void doStep(Software software) {		
		new ReleaseStep().doStep(software);
	}
	
	public static void main(String[] args) {
		Logger logger = Logger.getLogger(ReleaseStepWorker.class.getCanonicalName());
		try	{			
			final StepFrame releaseFrame = new StepFrame("Step5: Release", 400, 600);
			List<String> releaseInputQueues = new ArrayList<String>();
			releaseInputQueues.add(JMSMessagingConstants.RELEASE_INPUT);
			List<String> releaseOutputQueues = new ArrayList<String>();
			final IMessagingHandler<Software> messagingHandler = new SoftwareDevelopmentMessagingHandler(releaseFrame, releaseInputQueues, releaseOutputQueues);
			releaseFrame.getNextButton().addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					new ReleaseStepWorker(releaseFrame, messagingHandler).execute();
				}
			});
		}
		catch (Exception e) {
			logger.log(Level.SEVERE, "Error during initialization: ", e);
		}
	}

}
